﻿@{
    ViewBag.Title = "供应商联系人";
    
}
@using FMS.UI.Extension;
@section headSecion{
    <script type="text/javascript">
        $(function () {
            $.globalHelper.datagridPara.init("/Factory/FactoryContact/FactoryContactIndex", [@Html.GetSonBtnJs()], [
                [
                    { field: 'contact_Name', title: '姓名', width: 80 },
                    { field: 'contact_Phone', title: '电话', width: 80 },
                    { field: 'contact_Address', title: '地址', width: 80 },
                    {
                        field: 'Factory_Machines_Supplier',
                        title: '供应商名称',
                        width: 80,
                        formatter: function (colData) {
                            return colData.supplier_Name;
                        }
                    }
                ]
            ]);
            $("#tbList").datagrid($.globalHelper.datagridPara.paras);
        });

           @if (Html.IsBtnExist("btnShow"))
           {
               <text>
        function btnShow() {
            var cond = $("#btnShowId").val();
            if (cond == null || cond === "") {
                $.msgBoxObj.showInfo("请输入搜索条件");
            } else {
                window.setTimeout(function () {
                    $.extend($("#tbList").datagrid("options"), {
                        url: '/Factory/FactoryContact/FactoryContactBtnSearch', //这里定义url    
                        queryParams: {
                            "searchCondition": cond
                        }
                    });
                    $("#tbList").datagrid("load");
                }, 100); //延迟100毫秒执行   
            }

        }
           </text>
           }

        @if (Html.IsBtnExist("add"))
        {
            <text>

        function add() {
            $.globalHelper.showCommonWindow("新增联系人", "/Factory/FactoryContact/FactoryContactAdd", 370, 220);
        }
        </text>
        }

        @if (Html.IsBtnExist("remove"))
        {
            <text>

        function remove() {
            ifSelected(function (selectedRowData) {
                window.top.ComSkipMsg(selectedRowData, "/Factory/FactoryContact/FactoryContactDel");
            });
        }
        </text>
        }

      

        @if (Html.IsBtnExist("modify"))
        {
            <text>
        function modify() {

            ifSelected(function (selectedRowData) { $.globalHelper.showCommonWindow("修改联系人", "/Factory/FactoryContact/FactoryContactModify/" + selectedRowData.contact_Id, 370, 220) });
        }
        </text>
        }

        //统一判断是否有选中行 有则调用回掉函数(func) 并存入选中行的数据
        function ifSelected(func) {
            //获取选中行数据
            var selectedRowData = $("#tbList").datagrid("getSelected");
            if (selectedRowData) {
                if (func && func instanceof Function) {
                    func(selectedRowData);
                }


            } else {
                $.msgBoxObj.showInfo("请选中要操作的行");
            }
        }
</script>
}

<table id="tbList" style="width:100%"></table>
